#region Using

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Text;
using EstateNuke.Data;
using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms;
using System.Linq;

#endregion

namespace EstateNuke.BusinessSystem.Controls.EstateControls
{
    public partial class BuildingTitleItemControl : UserControl
    {
        private Building _currentBuilding;
        private RoomState _currentRoomState;

        public BuildingTitleItemControl(Building building, RoomState roomState)
        {
            _currentBuilding = building;
            _currentRoomState = roomState;
            InitializeComponent();
            BindBuildingTitleItem();
        }

        private void BindBuildingTitleItem()
        {
            int roomCount = _currentBuilding.Rooms.Count(c => c.RoomState == _currentRoomState);

            lblRoomCount.Text = roomCount.ToString();

            pnlRoomType.BackColor = Color.FromArgb(int.Parse(_currentRoomState.Color, NumberStyles.HexNumber));
            lblRoomTypeName.Text = _currentRoomState.Name;
        }

        private void BuildingTitleItemControl_Load(object sender, EventArgs e)
        {
            lblRoomCount.Left = pnlRoomType.Width / 2 - lblRoomCount.Width / 2;
        }
    }
}